package cn.aitrox.ry.service.anno.dao.impl;

import cn.aitrox.ry.common.dao.MapperSqlCallback;
import cn.aitrox.ry.common.dao.impl.BaseDaoImpl;
import cn.aitrox.ry.service.anno.dao.TaskUserDao;
import cn.aitrox.ry.service.anno.entity.TaskUserEntity;
import cn.aitrox.ry.service.anno.mapper.TaskUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class TaskUserDaoImpl extends BaseDaoImpl<TaskUserEntity> implements TaskUserDao {

    @Autowired
    private TaskUserMapper mapper;

    @Override
    public List<TaskUserEntity> findByTaskId(Integer taskId) {
        TaskUserEntity cond = new TaskUserEntity();
        cond.setTaskId(taskId);
        return findByCondition(cond, null);
    }

    @Override
    public void batchSave(List<TaskUserEntity> list) {
        batchInsert(list, 1000, new MapperSqlCallback<TaskUserEntity>() {
            @Override
            public void batchInsert(List<TaskUserEntity> objList) {
                mapper.batchInsert(objList);
            }
        });
    }

    @Override
    public void deleteByTaskId(Integer taskId) {
        mapper.deleteByTaskId(taskId);
    }
}
